< previous page page_98 next page >

Page 98
0098-01.jpg
Figure 3.6
Example program LogIndex displays the colors
used in a picture's logical palette.
The program then uses the following code to fill the right picture box with rectangles containing each of the colors in its logical palette. The program defines the constant PALETTE_INDEX = &H1000000 to make the code a little easier to understand.
e10a6a0a59f035e870d90cca05b85fce.gif
Option Explicit

Private Const PALETTE_INDEX = &H1000000

' Fill picture box Pal with its logical palette
' colors using palette indexes.
Private Sub FillPicture()
Dim i As Integer
Dim j As Integer
Dim dx As Single
Dim dy As Single
Dim clr As Long

    dx = picPalette.ScaleWidth / 16
    dy = picPalette.ScaleHeight / 16
    clr = 0
    For i = 0 To 16
        For j = 0 To 16
            picPalette.Line (j * dx, i * dy)-Step(dx, dy), _
                clr + PALETTE_INDEX, BF
            clr = clr + 1
        Next j
    Next i
End Sub

 
< previous page page_98 next page >